﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BT_DoHoa_Nhom13.EffectLib
{
    public class ShadowEffect : MyEffect
    {
        const int DEPTH = 10;
        static MyEffect instance;
        public static MyEffect GetInstance()
        {
            if(instance == null)
            {
                instance = new ShadowEffect();
            }

            return instance;
        }

        private ShadowEffect()
        {
            name = "Shadow";
            kind = KIND.BOTTOM;
        }

        public override void Draw(MyGraphic graphic, MyShape shape)
        {
            MyShape shapeEffect = shape.Clone();
            this.CreateShadow(shapeEffect);
            shapeEffect.SetFill(true);
            shapeEffect.Draw(graphic,null);
        }

        private void CreateShadow(MyShape shape)
        {
            int top, left, width, height;
            shape.SetConfig(out top, out left, out width, out height);
           
            left += DEPTH;
            top += DEPTH;
            shape.SetStartPoint(left, top);
            shape.SetEndPoint(left + width, top + height);
        }
    }
}
